<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台首页</title>
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap-rtl.css" />
    <script type="text/javascript" src="/php/tpblog/public/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/BootStrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/js/layer.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">بىلوگ سېستىىسى </a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li <?php if(CONTROLLER_NAME == 'Index'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Index/index');?>">باشبەت <span class="sr-only">(current)</span></a></li>
                <li <?php if(CONTROLLER_NAME == 'Category'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Category/index');?>">مەزمۇن</a></li>
                <li <?php if(CONTROLLER_NAME == 'User'): ?>class="active"<?php endif; ?>><a href="<?php echo U('User/index');?>">باشقۇرغۇچىلار</a></li>
                <li <?php if(CONTROLLER_NAME == 'Navs'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Navs/index');?>">ئىقتىدار</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/php/tpblog/index.php" target="_blank">ئالدى بەت</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">ياخشىمۇسىز <?php echo ($sessions['auser']); ?><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <?php $a_aid=$sessions['aid'] ?>
                         <li><a href="<?php echo U('User/edit',array('aid'=>$a_aid));?>">ئارخىب تەھرىرلەش</a></li>
                        <li><a href="<?php echo U('Index/logout');?>">بىخەتەر چېكىنىش </a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

    <div class="container">
        <div class="row">
            <div class="col-md-2">
                <a style="width: 150px" href="##" class="btn btn-primary"> باشقۇرغۇچىلار</a>
            </div>
            <div class="col-md-10">
                  <div class="page-header"><h4>ئەزالار تىزىملىكى</h4></div>
                <div class="btn-group" role="group" aria-label="...">
                    <a href="<?php echo U('User/index');?>" type="button" class="btn btn-default">بارلىق باشقۇرغۇچى</a>
                    <a href="<?php echo U('User/add');?>" type="button" class="btn btn-default">يېڭىدىن قوشۇش</a>
                </div>
                <br><br>
                <table class="table table-bordered">
                   <thead>
                        <tr class="active">
                            <td width="30">ID</td>
                            <td>ئېلىخەت</td>
                            <td>ئىسمى</td>
                            <td>تىزىملاتقان ۋاقىت</td>
                            <td>ھالىتى</td>
                            <td>مەشغۇلات</td>
                        </tr>
                   </thead>
                    <tbody>
                        <?php if(is_array($users)): foreach($users as $key=>$u): ?><tr>
                                <td><?php echo ($u['aid']); ?></td>
                                <td class="text-left" style="direction: ltr"><?php echo ($u['email']); ?></td>
                                <td><?php echo ($u['auser']); ?></td>
                                <td class="text-left" style="direction: ltr"><?php echo (date("Y-m-d H:i",$u['intime'] )); ?></td>
                                <td>
                                    <?php if($u['status']): ?><span class="label label-success">ئوچۇق</span>
                                        <?php else: ?>
                                        <span class="label label-danger">تاقاق</span><?php endif; ?>
                                </td>
                                <td>
                                    <a href="<?php echo U('User/edit',array('aid'=>$u['aid']));?>" class="label label-success">تەھرىرلەش</a>
                                    <?php if($_SESSION['name'] != $u['aid']): ?><a href="javascript:deleteUser(<?php echo ($u['aid']); ?>);" class="label label-danger">ئۆچۈرۈش</a><?php endif; ?>
                                </td>
                            </tr><?php endforeach; endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<script type="text/javascript">
    //删除提示框
    function deleteUser(aid) {
        //询问框
        layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
            btn: ['ھەئە','ياق'] //按钮
        }, function(){
            $.ajax({
                'url':"<?php echo U('User/delete');?>",
                'type':'POST',
                'dataType':'json',
                'data':{'aid':aid},
                success:function (phpRetrnData) {
                    console.log(phpRetrnData);
                    if(phpRetrnData.status){
                        layer.msg(phpRetrnData.message,{'icon':6},function () {
                            window.location=location;
                        })
                    }else {
                        layer.msg(phpRetrnData.message,{'icon':5});
                    }
                }
            })
        });
    }
</script>
</body>
</html>